//
//  SecondScrollDetailViewController.m
//  DesighBook
//
//  Created by 梅明 on 15/9/21.
//  Copyright (c) 2015年 梅明. All rights reserved.
//

#import "SecondScrollDetailViewController.h"
#import "customCollectionViewCell.h"
#import "DesighModel.h"
#import "MainViewController.h"

@interface SecondScrollDetailViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
@property (weak, nonatomic) IBOutlet UICollectionView *myCollectionView;

@end

@implementation SecondScrollDetailViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    _myCollectionView.pagingEnabled = YES;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
}

-(void)viewDidLayoutSubviews
{
    _myCollectionView.contentOffset = CGPointMake(self.view.frame.size.width*_index, 0);

}

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return  CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
}

- (IBAction)back:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _array.count;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    customCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"customCollectionViewCell" forIndexPath:indexPath];
    cell.zoomImageView.image = nil;
    DesighModel *model = _array[indexPath.row];
//    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(cell.frame.size.width/2-30, 25, 60, 30)];
//    label.text = @"";
//    label.text = [NSString stringWithFormat:@"%ld/%ld",indexPath.row+1,_array.count];
//    label.textColor = [UIColor whiteColor];
//    label.textAlignment = UITextAlignmentCenter;
//    [cell addSubview:label];
    [cell createTableviewWithId:model.numberid];
    return cell;
}

//- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
//    NSLog(@"scrollView.contentOffset.x = %lf", scrollView.contentOffset.x);
//    
//        NSInteger index = scrollView.contentOffset.x/self.view.frame.size.width;
//        _titlelabel.text = [NSString stringWithFormat:@"%02ld/%ld", index + 1,_array.count];
//}



@end
